<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2021/6/11
  Time: 9:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html class="no-js" lang="zxx">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Shop | eCommers</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/x-icon" href="assets/img/icon/favicon.png">

    <jsp:include page="${pageContext.request.contextPath}/common/css.jsp"></jsp:include>
</head>
<body>
<jsp:include page="${pageContext.request.contextPath}/common/Header.jsp"></jsp:include>
<main>
    <!--================Cart Area =================-->
    <section class="cart_area">
        <div class="container">
            <div class="cart_inner">
                <div class="table-responsive">
                    <table class="table">
                        <thead>
                        <tr>
                            <th scope="col">Product</th>
                            <th scope="col">Price</th>
                            <th scope="col">Quantity</th>
                            <th scope="col">Total</th>
                        </tr>
                        </thead>
                        <tbody>
                        <!--购物车开始-->
                        <c:forEach items="${cartEntryList}" var="List">
                        <tr>
                            <td>
                                <div class="media">
                                    <div class="media-body">
                                        <p>${List.product.productName}</p>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <h5>${List.product.price}</h5>
                            </td>
                            <form action="${pageContext.request.contextPath}/cart/changeProductNumber.do?productid=${List.product.productid}" method="post">
                            <td>
                                <div class="product_count">
                                    <input class="input-number2" name="number" type="text" value="${List.count}" min="0" max="10">
                                </div>
                            <td>
                                <h5>$${List.product.price*List.count}</h5>
                            </td>
                            <td>
                                <a href="${pageContext.request.contextPath}/cart/deleteCartProduct.do?productid=${List.product.productid}"><h5>删除商品</h5></a>
                            </td>
                            <td>
                                <input type="submit" class="btn" value="更新产品">
                            </td>
                            </form>
                        </tr>
                        </c:forEach>
                        <tr class="bottom_button">
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td></td>
                            <td>
                                <h5>总计</h5>
                            </td>
                            <td>
                                <c:set var="sum" value="0"></c:set>
                                <c:forEach items="${cartEntryList}" var="row" varStatus="status">
                                    <c:set var="sum" value="${sum+(row.product.price*row.count)}"></c:set>
                                </c:forEach>
                                <h5>$${sum}</h5>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="checkout_btn_inner float-right">
                        <a class="btn" href="${pageContext.request.contextPath}/product/showAll.do">继续购物</a>
                        <a class="btn checkout_btn" href="${pageContext.request.contextPath}/order/confOrder.do">结算</a>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!--================End Cart Area =================-->
</main>
<jsp:include page="${pageContext.request.contextPath}/common/Foot.jsp"></jsp:include>

<jsp:include page="${pageContext.request.contextPath}/common/js.jsp"></jsp:include>
</body>
</html>